package cuckoo.log.impl.log4j;

import org.apache.log4j.Level;

import cuckoo.log.Logger;
import cuckoo.log.util.MessageFormatter;

public class Log4jLoggerImpl implements Logger {

	private static String FQCN = Log4jLoggerImpl.class.getName();

	private org.apache.log4j.Logger logger;

	public Log4jLoggerImpl(Class<?> clazz) {
		this.logger = org.apache.log4j.Logger.getLogger(clazz);
	}

	public Log4jLoggerImpl(String loggerName) {
		this.logger = org.apache.log4j.Logger.getLogger(loggerName);
	}

	@Override
	public void debug(String msg) {
		logger.log(FQCN, Level.DEBUG, msg, null);
	}

	@Override
	public void debug(String msg, Throwable e) {
		logger.log(FQCN, Level.DEBUG, msg, e);
	}

	@Override
	public void debug(String msg, Object... args) {
		logger.log(FQCN, Level.DEBUG, MessageFormatter.arrayFormat(msg, args).getMessage(), null);
	}

	@Override
	public void info(String msg) {
		logger.log(FQCN, Level.INFO, msg, null);
	}

	@Override
	public void info(String msg, Throwable e) {
		logger.log(FQCN, Level.INFO, msg, e);
	}

	@Override
	public void info(String msg, Object... args) {
		logger.log(FQCN, Level.INFO, MessageFormatter.arrayFormat(msg, args).getMessage(), null);
	}

	@Override
	public void warn(String msg) {
		logger.log(FQCN, Level.WARN, msg, null);
	}

	@Override
	public void warn(String msg, Throwable e) {
		logger.log(FQCN, Level.WARN, msg, e);
	}

	@Override
	public void warn(String msg, Object... args) {
		logger.log(FQCN, Level.WARN, MessageFormatter.arrayFormat(msg, args).getMessage(), null);
	}

	@Override
	public void error(String msg) {
		logger.log(FQCN, Level.ERROR, msg, null);
	}

	@Override
	public void error(String msg, Throwable e) {
		logger.log(FQCN, Level.ERROR, msg, e);
	}

	@Override
	public void error(String msg, Object... args) {
		logger.log(FQCN, Level.ERROR, MessageFormatter.arrayFormat(msg, args).getMessage(), null);
	}

}
